package org.budo.activiti.service.api;

import java.util.List;
import java.util.Map;

/**
 * @author lmw
 */
public interface BudoActivitiService {
    List<Map<String, Object>> listModel();

    Map<String, Object> findModelById(String modelId);

    /**
     * @return id
     */
    String createModel(String name, String key);

    /**
     * 更新
     */
    Boolean saveModel(String modelId, String name, String description, String jsonXml, String svgXml);

    Boolean deployModel(String modelId);

    Boolean deleteModel(String modelId);

    Boolean deleteDeploymentByModelId(String modelId);

    String findModelEditorJson(String modelId);

    void completeTask(String taskId, Map<String, Object> variables);

    List<String> listTaskIdByVariable(String variableName, String variableValue);

    List<String> listTaskProcessInstanceIdByVariable(String variableName, String variableValue);

    void deleteProcessInstances(List<String> processInstanceIds, String deleteReason);

    String findLastAssigneeByVariable(String variableName, String variableValue);

    /**
     * 有序的，时间正序
     */
    List<String> listHistoricActivityNameByVariable(String variableName, String variableValue);

    /**
     * @see #submitStartFormData(String, Map)
     */
    String startProcessInstanceByModelId(String modelId, Map<String, Object> variables);

    List<Map<String, Object>> listUserTaskForm(String taskId);

    void saveFormData(String taskId, Map<String, String> properties);

    List<Map<String, Object>> listHistoryFormPropertyByTaskId(String taskId);

    String findTaskIdByVariable(String name, String value);

    List<Map<String, Object>> listStartFormPropertyByTemplateId(String modelId);

    /**
     * @see #startProcessInstanceByModelId(String, Map)
     */
    String submitStartFormData(String modelId, Map<String, Object> properties);

    String findExecutionIdByVariable(String variableName, String variableValue);

    String findLastActivityIdByVariable(String variableName, String variableValue);

    List<Integer> listLastCandidateByVariable(String variableName, String variableValue);

    String findModelIdByprocessInstanceId(String processInstanceId);

    Map<String, Object> findHistoryFormPropertyByTaskIdAndFieldName(String taskId, String fieldName);

    Boolean updateHistoryDetail(String taskId, String fieldName, Object fieldValue);

    Object parseFieldValue(String taskId, String fieldName, Object fieldValue);

    Object findHistoryDetail(String taskId, String fieldName);
}